<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>循环右移</title>
  <script>
    // 9. 编写函数rightchange(char,n) 实现字符串char循环右移n位。比如rightchange("abcdefg",2) 返回"fgabcde"
    function work9(x, n) {
      //截取前段和后段
      var q = x.substring(0, x.length - n),
        h = x.substring(x.length - n);
      //返回拼接字符串
      return h + q;
    }
    console.log(work9("abcdefg", 2));
  </script>
</head>

<body>

</body>

</html>